﻿@model IList<Area>
@using NewLife;
@using NewLife.Web;
@using XCode;
@using XCode.Configuration;
@using XCode.Membership;
@using NewLife.Cube;
@{
    var fact = ViewBag.Factory as IEntityFactory;
    var page = ViewBag.Page as Pager;
    var set = ViewBag.PageSetting as PageSetting ?? PageSetting.Global;
    var provider = ManageProvider.Provider;
}

<div class="card card-flush">
    <div class="card-body">
        <div class="table-responsive dataTables_wrapper dt-bootstrap4">
            <table class="table table-hover table-row-bordered table-row-dashed align-middle gy-4">
                <thead>
                    <tr class="fs-4 text-muted">
                        @if (set.EnableSelect)
                        {
                            <th class="text-center" style="width:10px;">
                                <div class="form-check form-check-sm form-check-custom form-check-solid">
                                    <input class="form-check-input" type="checkbox" id="chkAll" title="全选" />
                                </div>
                            </th>
                        }
                        <th title="编码。行政区划编码"><a href="@Html.Raw(page.GetSortUrl("ID"))">编码</a></th>
                        <th><a href="@Html.Raw(page.GetSortUrl("Name"))">名称</a></th>
                        <th><a href="@Html.Raw(page.GetSortUrl("FullName"))">全名</a></th>
                        <th><a href="@Html.Raw(page.GetSortUrl("ParentID"))">父级</a></th>
                        <th class="text-center">下级</th>
                        <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Level"))">层级</a></th>
                        <th><a href="@Html.Raw(page.GetSortUrl("Kind"))">类型</a></th>
                        <th title="区号。电话区号"><a href="@Html.Raw(page.GetSortUrl("TelCode"))">区号</a></th>
                        <th title="邮编。邮政编码"><a href="@Html.Raw(page.GetSortUrl("ZipCode"))">邮编</a></th>
                        <th><a href="@Html.Raw(page.GetSortUrl("Longitude"))">经度</a></th>
                        <th><a href="@Html.Raw(page.GetSortUrl("Latitude"))">纬度</a></th>
                        <th data-bs-toggle="tooltip" title="字符串前缀相同越多，地理距离越近，8位精度19米，6位610米"><a href="@Html.Raw(page.GetSortUrl("GeoHash"))">地址编码</a></th>
                        <th class="text-center"><a href="@Html.Raw(page.GetSortUrl("Enable"))">启用</a></th>
                        @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
                        {
                            <th>操作</th>
                        }
                    </tr>
                </thead>
                <tbody>
                    @foreach (var entity in Model)
                    {
                        var pstr = entity.Parent != null ? (entity.Parent + "") : (entity.ParentID + "");
                        <tr>
                            @if (set.EnableSelect)
                            {
                                <td class="text-center">
                                    <div class="form-check form-check-sm form-check-custom form-check-solid">
                                        <input class="form-check-input" type="checkbox" name="keys" value="@entity.ID" />
                                    </div>
                                </td>
                            }
                            <td>@entity.ID</td>
                            <td>@entity.Name</td>
                            <td>@entity.FullName</td>
                            <td><a href="?Id=@entity.ParentID">@pstr</a></td>
                            <td class="text-center"><a href="?parentId=@entity.ID">下级</a></td>
                            <td class="text-center">@entity.Level</td>
                            <td>@entity.Kind</td>
                            <td>@entity.TelCode</td>
                            <td>@entity.ZipCode</td>
                            <td>@entity.Longitude</td>
                            <td>@entity.Latitude</td>
                            <td>@entity.GeoHash</td>
                            <td class="text-center">
                                @await Html.PartialAsync("_List_Data_Item_IconBoolean", entity.Enable)
                            </td>
                            @if (this.Has(PermissionFlags.Detail, PermissionFlags.Update, PermissionFlags.Delete))
                            {
                                <td>
                                    @await Html.PartialAsync("_List_Data_Action", (Object)entity)
                                </td>
                            }
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>

